﻿using UnityEngine;
using System.Collections;

public class KillOnTop : MonoBehaviour {

	public Transform weakness;

	Animator anim;

	void Start () {
		anim = GetComponent<Animator> ();
	}

	void OnCollisionEnter2D(Collision2D col) {
			
		if (col.gameObject.tag == "Player") {
			float height = col.contacts[0].point.y - weakness.position.y;
			if (height > 0) {
				Dies();
				col.rigidbody.AddForce(new Vector2(0,300));
			}
		}
	}

	void Dies() {
		anim.SetBool ("isKill", true);

		Destroy(this.gameObject, 1f);
	}
}
